package com.sky.controller.common;

import com.sky.result.Result;
import com.sky.service.CommonService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.io.IOException;

@RestController
@Slf4j
@Api(tags = "文件上传")
public class CommonController {

    @Resource
    CommonService commonService;
    @PostMapping("/admin/common/upload")
    @ApiOperation("文件上传")
    public Result<String> upload(@RequestParam MultipartFile file) throws IOException {
        Result<String> stringResult = commonService.insertUpload(file.getBytes(),file.getOriginalFilename());
        return stringResult;
    }
}
